<%@page import="com.situ.mvc.entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- 写了个公共类，把要导入的公共的文件写到一块，${ctx} -->	    
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>	        
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${ctx}/lib/bootstrap-3.3.7-dist/css/bootstrap.css" />
<script type="text/javascript" src="${ctx}/lib/jquery/jquery-1.11.1.js" ></script>
<script type="text/javascript" src="${ctx}/lib/bootstrap-3.3.7-dist/js/npm.js" ></script>
<script type="text/javascript" src="${ctx}/lib/layer-v3.1.1/layer/layer.js" ></script>
<script type="text/javascript" src="${ctx}/lib/bootstrap-3.3.7-dist/js/mylayer.js" ></script>
</head>
<body>
	<!--from表单，自己的网页地址  -->
	<!-- 点击按钮不但调用Id，还调用自己的方法 --> <!-- 这样传参必须加method="post"，不会覆盖参数 -->
	<form id="updata_form" action="${ctx}/student/update.action" method="post">
	<!-- value 默认显示拿到的值（拿到原来的值） -->
		<input type="hidden" name="id" value="${student.id}"/>
		姓名：<input type="text" name="name" value="${student.name}"/><br/>
		年龄：<input type="text" name="age" value="${student.age}"/><br/>
		 <div class="form-group">
		    <label for="studentgender">性别:</label>&nbsp;&nbsp;&nbsp;&nbsp;
		    <input type="radio" name="gender" value="男" checked />男 &nbsp;&nbsp;&nbsp;&nbsp;
			<input type="radio" name="gender" value="女" />女
		  </div>
		班级：<input type="text" readonly="readonly" name="banjiName" value="${student.banjiName}"/>
		
		更改：<select name="banjiId" >
	    		<c:forEach items="${list}" var="banji">
	    			<option value="${banji.id}">${banji.name}</option>
	    		</c:forEach>
			</select> 
		<br/> 
		<input type="button" onclick="update()" value="修改"/>
		<input type="reset" value="重置"/>
	</form>
	
	<script type="text/javascript">
		//提交表单	
		function update(){
			$.ajax({
				url : "${ctx}/student/update.action",
				type : "post",
				dataType : "json",
				data : $("#updata_form").serialize(),//表单拿到属性值
				success : function(data){
					if(data){
						mylayer.success("修改成功");
						//关弹窗
						var index = parent.layer.getFrameIndex(window.name);
						setTimeout(function(){
							parent.layer.close(index);
							window.parent.location.reload();
						},1000)
					} else {
						mylayer.errorMsg("修改失败");
					}
				}	
			});
		}
	</script>
</body>
</html>